package com.ruoyi.businessOrder.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ruoyi.businessOrder.domain.BusinessOrder;
import com.ruoyi.businessOrder.domain.dto.BusinessOrderDto;
import com.ruoyi.businessOrder.domain.dto.RefundApplyDto;
import com.ruoyi.businessOrder.domain.dto.RefundAuditDto;
import com.ruoyi.businessSku.domain.BusinessSku;
import com.ruoyi.employee.domain.Employee;
import com.ruoyi.organization.domain.Organization;

/**
 * 交易订单信息Service接口
 * 
 * @author ruoyi
 * @date 2025-06-11
 */
public interface IBusinessOrderService
{
    /**
     * 获取订单信息By商品id
     *
     * @return
     */
    public BusinessOrder selectBusinessOrderBySkuId(Long skuId);

    /**
     * 查询交易订单信息
     * 
     * @param orderId 交易订单信息主键
     * @return 交易订单信息
     */
    public BusinessOrder selectBusinessOrderByOrderId(Long orderId);

    /**
     * 查询交易订单信息列表
     * 
     * @param businessOrder 交易订单信息
     * @return 交易订单信息集合
     */
    public List<BusinessOrder> selectBusinessOrderList(BusinessOrder businessOrder);

    /**
     * 获取员工信息By员工编码
     *
     * @return
     */
    Employee selectEmployeeByCode(String employeeCode);

    /**
     * 获取员工信息By手机号
     *
     * @return
     */
    Employee selectEmployeeByPhone(String phone);

    /**
     * 获取组织信息By组织名称
     *
     * @return
     */
    Organization selectOrgIdByName(String orgName);

    /**
     * 获取订单信息By商品id
     *
     * @return
     */
    BusinessSku selectBusinessSkuBySkuId(Long skuId);

    /**
     * 新增交易订单信息
     *
     * @param businessOrder 交易订单信息
     * @return 结果
     */
    public BusinessOrder insertBusinessOrder(BusinessOrder businessOrder);

    /**
     * 修改交易订单信息
     * 
     * @param businessOrder 交易订单信息
     * @return 结果
     */
    public int updateBusinessOrder(BusinessOrder businessOrder);

    /**
     * 批量删除交易订单信息
     * 
     * @param orderIds 需要删除的交易订单信息主键集合
     * @return 结果
     */
    public int deleteBusinessOrderByOrderIds(Long[] orderIds);

    /**
     * 删除交易订单信息信息
     * 
     * @param orderId 交易订单信息主键
     * @return 结果
     */
    public int deleteBusinessOrderByOrderId(Long orderId);


    void successPay(String orderSn);

    void failPay(String orderSn);

    boolean isSuccessPay(String orderSn);

    /*
    * 创建订单
    *
    * */
    BusinessOrder createOrder(BusinessOrderDto payDto, String platform);

    /**
     * 根据订单号查询订单
     *
     * @param orderCode
     * @return
     */
    BusinessOrder getByOrderCode(String orderCode);

    /**
     * 根据员工id获取交易订单列表
     */
    List<BusinessOrder> selectBusinessOrderByEmployeeId(Long employeeId);

    /**
     * 根据员工id和支付状态获取交易订单列表
     */
    List<BusinessOrder> selectBusinessOrderByEmployeeIdAndPayStatus(Long employeeId, String payStatus);

    /**
     * 根据员工id和订单状态获取交易订单列表
     */
    List<BusinessOrder> selectBusinessOrderByEmployeeIdAndOrderStatus(Long employeeId, String orderStatus);

    /**
     * 小程序获取预支付id
     */
    HashMap<String, Object> miniAppGetPrePayId(Long orderId) throws Exception;

    /**
     * 通过JSAPI/小程序下单接口获取到发起支付的必要参数prepay_id,构造签名
     */
    Map<String, String> getWxpayParams(Long orderId, String orderNo, Integer totalFee, String openId) throws Exception;

    /**
     * 小程序关闭待支付订单
     */
    HashMap<String, Object> miniAppCloseOrder(Long orderId) throws Exception;

    /**
     * 小程序发起退款
     */
    HashMap<String, Object> miniAppRefund(Long orderId, String reason) throws Exception;

    /**
     * 更新订单状态
     */
    void updateOrderStatusByOrderId(Long orderId, String orderStatus);

    /**
     * 存储微信下单接口生成的二维码地址
     */
    void saveQrCodeUrl(Long orderId, String qrCodeUrl);

    /**
     * 申请退款
     */
    void applyRefund(RefundApplyDto refundApplyDto);

    /**
     * 退款申请审核
     */
    void auditRefundApplication(Long refundId, RefundAuditDto auditDto) throws Exception;

    /**
     * 获取业务订单列表时，将订单状态为'3'（退款中）的优先级设为最高，排在最前面
     * 获取交易订单列表
     */
    List<BusinessOrder> selectBusinessOrderSummaryList(BusinessOrder businessOrder);
}
